package mc

import (
	"gitee.com/dreamwood/ez-go/db/mgo"
)

const (
	BuyOrderEventNew           = "erp.BuyOrderNew"
	BuyOrderEventBeforeCreate  = "erp.BuyOrderBeforeCreate"
	BuyOrderEventBeforeUpdate  = "erp.BuyOrderBeforeUpdate"
	BuyOrderEventBeforeSave    = "erp.BuyOrderBeforeCreate erp.BuyOrderBeforeUpdate"
	BuyOrderEventAfterCreate   = "erp.BuyOrderAfterCreate"
	BuyOrderEventAfterUpdate   = "erp.BuyOrderAfterUpdate"
	BuyOrderEventAfterSave     = "erp.BuyOrderAfterCreate erp.BuyOrderAfterUpdate"
	BuyOrderEventDelete        = "erp.BuyOrderDelete"
	BuyOrderAccessControlEvent = "erp.BuyOrderAccessControl"
)

func GetBuyOrderConfig() *mgo.DocConfig {
	return BuyOrder_Config
}

var BuyOrder_Config *mgo.DocConfig

func init() {
	BuyOrder_Config = NewBuyOrderConfig()
}
func NewBuyOrderConfig() *mgo.DocConfig {
	return &mgo.DocConfig{
		ContainerKey: "erp.BuyOrder",
		Fields: []string{
			"sn", "title", "seller", "sellerName", "taxType", "payType", "payCashType", "deliverType", "deliverAt", "deliver", "contactEmp", "contact", "contactPhone", "num", "money", "status", "isConfirm", "confirmAt", "isCancel", "isLock", "approvalSate", "approvalStage", "formAt", "formEmp", "createEmp", "note", "product",
		},
		RelationFields: []string{
			"seller", "taxType", "payType", "payCashType", "deliverType", "contactEmp", "status", "formEmp", "createEmp", "product",
		},
		RelationConfigs: map[string]*mgo.DocRelation{
			"seller": {
				Config:     GetSellerConfig,
				DocName:    "Seller",
				JoinType:   "O",
				KeyInside:  "sellerId",
				KeyOutSide: "id",
			},
			"taxType": {
				Config:     GetTaxTypeConfig,
				DocName:    "TaxType",
				JoinType:   "O",
				KeyInside:  "taxTypeId",
				KeyOutSide: "id",
			},
			"payType": {
				Config:     GetPayTypeConfig,
				DocName:    "PayType",
				JoinType:   "O",
				KeyInside:  "payTypeId",
				KeyOutSide: "id",
			},
			"payCashType": {
				Config:     GetPayCashTypeConfig,
				DocName:    "PayCashType",
				JoinType:   "O",
				KeyInside:  "payCashTypeId",
				KeyOutSide: "id",
			},
			"deliverType": {
				Config:     GetDeliverTypeConfig,
				DocName:    "DeliverType",
				JoinType:   "O",
				KeyInside:  "deliverTypeId",
				KeyOutSide: "id",
			},
			"contactEmp": {
				Config:     GetEmpConfig,
				DocName:    "Emp",
				JoinType:   "O",
				KeyInside:  "contactEmpId",
				KeyOutSide: "id",
			},
			"status": {
				Config:     GetBuyOrderStatusConfig,
				DocName:    "BuyOrderStatus",
				JoinType:   "O",
				KeyInside:  "statusId",
				KeyOutSide: "id",
			},
			"formEmp": {
				Config:     GetEmpConfig,
				DocName:    "Emp",
				JoinType:   "O",
				KeyInside:  "formEmpId",
				KeyOutSide: "id",
			},
			"createEmp": {
				Config:     GetEmpConfig,
				DocName:    "Emp",
				JoinType:   "O",
				KeyInside:  "createEmpId",
				KeyOutSide: "id",
			},
			"product": {
				Config:     GetBuyOrderProductConfig,
				DocName:    "BuyOrderProduct",
				JoinType:   "M",
				KeyInside:  "id",
				KeyOutSide: "belongToId",
			},
		},
		FieldFilter: map[string]*mgo.DocFieldFilter{
			"default": {
				Select: []string{},
				Omit:   []string{},
			},
		},
	}
}
